<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>帖子详情</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .post-detail {
            margin-bottom: 20px;
            padding: 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
        }
    </style>
</head>
<body>
<div class="container mt-5">
    <h2>帖子详情</h2>

    <!-- 帖子详情卡片 -->
    <div class="post-detail">
        <h4 th:text="${context.title}"></h4>
        <p th:text="${context.context}"></p>
        <small class="text-muted">作者：[[${context.userId}]] | 发布时间：[[${#temporals.format(context.createTime, 'yyyy-MM-dd HH:mm')}]]</small>
    </div>

    <!-- 评论列表 -->
    <div class="mt-5">
        <h3>评论</h3>
        <div th:each="comment : ${comments}" class="card mb-3">
            <div class="card-body">
                <p th:text="${comment.content}"></p>
                <small class="text-muted">评论者：[[${comment.userId}]] | 评论时间：[[${#temporals.format(comment.createTime, 'yyyy-MM-dd HH:mm')}]]</small>
            </div>
        </div>
    </div>

    <!-- 评论输入框 -->
    <div class="mt-4">
        <form th:action="@{/user/comment/add}" method="post">
            <input type="hidden" name="contextId" th:value="${context.id}">
            <div class="form-group">
                <textarea class="form-control" name="content" rows="3" placeholder="请输入您的评论"></textarea>
            </div>
            <button type="submit" class="btn btn-primary mt-2">提交评论</button>
        </form>
    </div>

    <!-- 返回按钮 -->
    <div class="mt-4 text-center">
        <a th:href="@{/user/index}" class="btn btn-secondary">返回首页</a>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>